package com.longrise.android.byjk.plugins.request;

import android.os.Bundle;

import com.longrise.LEAP.Base.Objects.EntityBean;
import com.longrise.android.byjk.model.UserInfor;
import com.longrise.android.byjk.plugins.aboutme.personalInfo.PersonalPresenter;

/**
 * Created by sujizhong on 2016/12/21.
 * 设计修改用户信息的接口封装请求参数
 */

public class ChangeInforRequest extends AppBaseRequest {

    private AppBaseResult mResult = null;
    private String mApi;

    public ChangeInforRequest() {
    }

    public ChangeInforRequest(AppBaseResult result) {
        this.mResult = result;
    }

    @Override
    public Object getRequestParams() {
        return null;
    }

    /**
     * @param extraParams 附加参数
     *                    如果请求中需要附加参数，使用该方法
     */
    @Override
    public Object getRequestParams(Bundle extraParams) {
        return super.getRequestParams(extraParams);
    }

    /**
     * @param tag         可能会存在同一个接口修改不同信息，使用api无法做区分时，使用该标记
     * @param extraBundle 附加参数
     */
    @Override
    public Object getRequestParams(int tag, Bundle extraBundle) {
        EntityBean bean = new EntityBean();
        bean.set("precardno", UserInfor.getInstance().getUsersfzh());
        bean.set("userid", UserInfor.getInstance().getUserid());
        switch (mApi) {
            case "bbt_user_iInsuranceProduct":  //添加产品
                bean.set("productname", extraBundle.getString("productname"));
                bean.set("productdesc", extraBundle.getString("productdesc"));
                break;

            case "bbt_user_uInsuranceProduct":  //修改产品
                bean.set("productname", extraBundle.getString("productname"));
                bean.set("productdesc", extraBundle.getString("productdesc"));
                bean.set("productid", extraBundle.getString("id"));
                break;

            case "bbt_user_uLocalDevCert":  //修改执业信息
                bean.set("cardno", UserInfor.getInstance().getUsersfzh());
                bean.set("certtype", extraBundle.getString("certtype"));
                bean.set("qualificationtype", extraBundle.getString("qualificationtype"));
                bean.set("orgname", extraBundle.getString("orgname"));
                bean.set("scopecodename", extraBundle.getString("scopecodename"));
                bean.set("scopeareaname", extraBundle.getString("scopeareaname"));
                bean.set("workingyears", extraBundle.getString("workingyears"));
                break;

            case "bbt_user_sDevCertInfo": //查询执业信息
                bean.set("cardno", UserInfor.getInstance().getUsersfzh());
                break;

            case "bbt_user_uploadServerImg": //修改头像
                bean.set("cardno", UserInfor.getInstance().getUsersfzh());
                bean.set("userid", UserInfor.getInstance().getUserid());
                bean.set("bytestr", extraBundle.getString("bytestr"));
                break;

            case "bbt_getAppEntryPath": //查询展业秀
                bean.set("urltype", "grzy");
                break;

            case "bbt_user_uPersonInfo": //修改个人资料，昵称，身份证号等等
                if (tag == PersonalPresenter.CHANGENICKNAME) {
                    bean.set("nickname", extraBundle.getString("nickname"));
                } else if (tag == PersonalPresenter.CHANGETRUENAME) {
                    bean.set("personname", extraBundle.getString("personname"));
                } else if (tag == PersonalPresenter.CHANGEIDNUMBER) {
                    bean.set("cardno", extraBundle.getString("cardno"));
                } else if (tag == PersonalPresenter.CHANGEPHONENUMBER) {
                    bean.set("mobile", extraBundle.getString("mobile"));
                } else if (tag == PersonalPresenter.CHANGEPROFILE) {
                    bean.set("profile", extraBundle.getString("profile"));
                }
                break;

            default:
                break;
        }
        EntityBean reqBean = new EntityBean();
        reqBean.set("bean", bean);
        return reqBean;
    }

    /**
     * @return 返回AppBaseResult回调
     */
    @Override
    public AppBaseResult getResult() {
        return mResult;
    }

    /**
     * 设置回调解析
     *
     * @param result
     */
    @Override
    public void setResult(AppBaseResult result) {
        this.mResult = result;
    }

    /**
     * 返回当前调用的api
     */
    @Override
    public String getApi() {
        return mApi;
    }

    /**
     * 设置当前请求的api
     *
     * @param api
     */
    @Override
    public void setApi(String api) {
        this.mApi = api;
    }
}
